package com.example.a2032.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.a2032.db.DataDbHelper;
import com.example.a2032.db.dao.ClockDataDao;
import com.example.a2032.livedatas.SingleSourceLiveData;
import com.example.a2032.entity.JstyleClock;

import java.util.List;

public class ClockDataViewModel extends AndroidViewModel {

    private final SingleSourceLiveData<List<JstyleClock>> realTimeStepObservable;
    ClockDataDao clockDataDao;

    public ClockDataViewModel(@NonNull Application application) {
        super(application);
        clockDataDao = DataDbHelper.getInstance(application).getClockDataDao();
        realTimeStepObservable = new SingleSourceLiveData<>();
    }

    public LiveData<List<JstyleClock>> getAllClock() {
        realTimeStepObservable.setSource(clockDataDao.loadAllClock());
        return realTimeStepObservable;
    }
}
